﻿using System;
using System.IO;
using Character;
using UnityEngine;

/// <summary>游戏存档数据 </summary>
public class GamePlayData
{
	// Token: 0x06001324 RID: 4900 RVA: 0x00089B20 File Offset: 0x00087D20
	public GamePlayData()
	{
		for (int i = 0; i < this.personality.Length; i++)
		{
			this.personality[i] = new Personality();
		}
		this.Clear();
	}

	// Token: 0x170001C3 RID: 451
	// (get) Token: 0x06001325 RID: 4901 RVA: 0x00089B80 File Offset: 0x00087D80
	public SaveHeader Header
	{
		get
		{
			return this.header;
		}
	}

	// Token: 0x170001C4 RID: 452
	// (get) Token: 0x06001326 RID: 4902 RVA: 0x00089B88 File Offset: 0x00087D88
	// (set) Token: 0x06001327 RID: 4903 RVA: 0x00089B90 File Offset: 0x00087D90
	public GamePlayData.PROGRESS Progress
	{
		get
		{
			return this.progress;
		}
		set
		{
			this.SetProgress(value);
		}
	}

	// Token: 0x06001328 RID: 4904 RVA: 0x00089B9C File Offset: 0x00087D9C
	public void Clear()
	{
		this.progress = GamePlayData.PROGRESS.FIRST_RITSUKO;
		for (int i = 0; i < this.personality.Length; i++)
		{
			this.personality[i].Init();
		}
		this.personality[3].expLikeSperm = 999;
		this.personality[3].likeSperm = true;
		this.lastSelectMale = MALE_ID.HERO;
		this.lastSelectFemale = HEROINE.RITSUKO;
		this.lastSelectVisitor = VISITOR.NONE;
		this.lastSelectMap = 0;
		this.lastSelectTimeZone = 0;
		this.unlockWeaknessRecovery = false;
		this.unlockShowHitArea = false;
		this.unlockFastXtc = false;
		this.readAllFreeMessage = false;
	}

	// Token: 0x06001329 RID: 4905 RVA: 0x00089C38 File Offset: 0x00087E38
	public void Start()
	{
		this.Clear();
		TextAsset textAsset = AssetBundleLoader.LoadAsset<TextAsset>(GlobalData.assetBundlePath, "def_card", "MaleA");
		this.custom_hero = new CustomParameter(SEX.MALE);
		if (textAsset != null)
		{
			this.custom_hero.Load(textAsset, false, true);
		}
		textAsset = AssetBundleLoader.LoadAsset<TextAsset>(GlobalData.assetBundlePath, "def_card", "FemaleA");
		this.custom_ritsuko = new CustomParameter(SEX.FEMALE);
		if (textAsset != null)
		{
			this.custom_ritsuko.Load(textAsset, true, false);
		}
		this.personality[0] = new Personality();
		this.personality[0].feelAnus = true;
		this.personality[0].expFeelAnus = 999;
		textAsset = AssetBundleLoader.LoadAsset<TextAsset>(GlobalData.assetBundlePath, "def_card", "FemaleB");
		this.custom_akiko = new CustomParameter(SEX.FEMALE);
		if (textAsset != null)
		{
			this.custom_akiko.Load(textAsset, true, false);
		}
		this.personality[1] = new Personality();
		this.personality[1].indecentLanguage = true;
		this.personality[1].expIndecentLanguage = 999;
		textAsset = AssetBundleLoader.LoadAsset<TextAsset>(GlobalData.assetBundlePath, "def_card", "FemaleC");
		this.custom_yukiko = new CustomParameter(SEX.FEMALE);
		if (textAsset != null)
		{
			this.custom_yukiko.Load(textAsset, true, false);
		}
		this.personality[2] = new Personality();
		this.personality[2].feelVagina = true;
		this.personality[2].expFeelVagina = 999;
		this.personality[2].vaginaVirgin = false;
		this.personality[2].analVirgin = true;
		textAsset = AssetBundleLoader.LoadAsset<TextAsset>(GlobalData.assetBundlePath, "def_card_05", "FemaleD");
		this.custom_mariko = new CustomParameter(SEX.FEMALE);
		if (textAsset != null)
		{
			this.custom_mariko.Load(textAsset, true, false);
		}
		Personality personality = this.personality[3] = new Personality();
		personality.expLikeSperm = 999;
		personality.likeSperm = true;
		textAsset = AssetBundleLoader.LoadAsset<TextAsset>(GlobalData.assetBundlePath, "def_card", "MaleB");
		this.custom_kouichi = new CustomParameter(SEX.MALE);
		if (textAsset != null)
		{
			this.custom_kouichi.Load(textAsset, false, true);
		}
		textAsset = AssetBundleLoader.LoadAsset<TextAsset>(GlobalData.assetBundlePath, "def_card", "MobA");
		this.custom_h_maleMobA = new CustomParameter(SEX.MALE);
		if (textAsset != null)
		{
			this.custom_h_maleMobA.Load(textAsset, false, true);
		}
		textAsset = AssetBundleLoader.LoadAsset<TextAsset>(GlobalData.assetBundlePath, "def_card", "MobB");
		this.custom_h_maleMobB = new CustomParameter(SEX.MALE);
		if (textAsset != null)
		{
			this.custom_h_maleMobB.Load(textAsset, false, true);
		}
		textAsset = AssetBundleLoader.LoadAsset<TextAsset>(GlobalData.assetBundlePath, "def_card", "MobC");
		this.custom_h_maleMobC = new CustomParameter(SEX.MALE);
		if (textAsset != null)
		{
			this.custom_h_maleMobC.Load(textAsset, false, true);
		}
	}

	// Token: 0x0600132A RID: 4906 RVA: 0x00089F24 File Offset: 0x00088124
	public void Save(string path, string comment)
	{
		FileStream fileStream = null;
		try
		{
			fileStream = File.OpenWrite(path);
		}
		catch (Exception ex)
		{
			MonoBehaviour.print(string.Concat(new object[]
			{
				"ファイルが開けません:",
				path,
				" ",
				ex
			}));
			return;
		}
		BinaryWriter binaryWriter = new BinaryWriter(fileStream);
		this.header.version = 5;
		this.header.comment = comment;
		this.header.SetNowTime();
		this.header.Save(binaryWriter);
		binaryWriter.Write((int)this.progress);
		this.custom_hero.Save(binaryWriter);
		this.custom_kouichi.Save(binaryWriter);
		this.custom_h_maleMobA.Save(binaryWriter);
		this.custom_h_maleMobB.Save(binaryWriter);
		this.custom_h_maleMobC.Save(binaryWriter);
		binaryWriter.Write(4);
		this.custom_ritsuko.Save(binaryWriter);
		this.custom_akiko.Save(binaryWriter);
		this.custom_yukiko.Save(binaryWriter);
		this.custom_mariko.Save(binaryWriter);
		for (int i = 0; i < this.personality.Length; i++)
		{
			this.personality[i].Save(binaryWriter);
		}
		binaryWriter.Write((int)this.lastSelectMale);
		binaryWriter.Write((int)this.lastSelectFemale);
		binaryWriter.Write((int)this.lastSelectVisitor);
		binaryWriter.Write(this.lastSelectMap);
		binaryWriter.Write(this.lastSelectTimeZone);
		binaryWriter.Write(this.unlockWeaknessRecovery);
		binaryWriter.Write(this.unlockShowHitArea);
		binaryWriter.Write(this.unlockFastXtc);
		binaryWriter.Write(this.readAllFreeMessage);
		binaryWriter.Write(this.readAllFreeWithAdd);
		fileStream.Close();
	}

	// Token: 0x0600132B RID: 4907 RVA: 0x0008A0D8 File Offset: 0x000882D8
	public void Load(string path)
	{
		FileStream fileStream = null;
		try
		{
			fileStream = File.OpenRead(path);
		}
		catch
		{
			return;
		}
		if (fileStream == null)
		{
			return;
		}
		BinaryReader binaryReader = new BinaryReader(fileStream);
		if (!this.header.Load(binaryReader))
		{
			fileStream.Close();
			return;
		}
		this.Clear();
		this.progress = (GamePlayData.PROGRESS)binaryReader.ReadInt32();
		this.custom_hero.Load(binaryReader);
		this.custom_kouichi.Load(binaryReader);
		this.custom_h_maleMobA.Load(binaryReader);
		this.custom_h_maleMobB.Load(binaryReader);
		this.custom_h_maleMobC.Load(binaryReader);
		int num = binaryReader.ReadInt32();
		this.custom_ritsuko.Load(binaryReader);
		this.custom_akiko.Load(binaryReader);
		this.custom_yukiko.Load(binaryReader);
		if (this.header.version >= 4)
		{
			this.custom_mariko.Load(binaryReader);
		}
		if (num < 4)
		{
		}
		for (int i = 0; i < num; i++)
		{
			this.personality[i].Load(binaryReader, this.header.version);
		}
		this.lastSelectMale = (MALE_ID)binaryReader.ReadInt32();
		this.lastSelectFemale = (HEROINE)binaryReader.ReadInt32();
		this.lastSelectVisitor = (VISITOR)binaryReader.ReadInt32();
		this.lastSelectMap = binaryReader.ReadInt32();
		this.lastSelectTimeZone = binaryReader.ReadInt32();
		if (this.header.version >= 2)
		{
			this.unlockWeaknessRecovery = binaryReader.ReadBoolean();
			this.unlockShowHitArea = binaryReader.ReadBoolean();
			this.unlockFastXtc = binaryReader.ReadBoolean();
			this.readAllFreeMessage = binaryReader.ReadBoolean();
		}
		if (this.header.version >= 5)
		{
			this.readAllFreeWithAdd = binaryReader.ReadBoolean();
		}
		fileStream.Close();
	}

	// Token: 0x0600132C RID: 4908 RVA: 0x0008A2A0 File Offset: 0x000884A0
	public Personality GetHeroinePersonality(HEROINE id)
	{
		if (id >= HEROINE.RITSUKO && id < HEROINE.NUM)
		{
			return this.personality[(int)id];
		}
		return null;
	}

	// Token: 0x0600132D RID: 4909 RVA: 0x0008A2C8 File Offset: 0x000884C8
	public CustomParameter GetHeroineCustomParam(HEROINE heroineID)
	{
		if (heroineID == HEROINE.RITSUKO)
		{
			return this.custom_ritsuko;
		}
		if (heroineID == HEROINE.AKIKO)
		{
			return this.custom_akiko;
		}
		if (heroineID == HEROINE.YUKIKO)
		{
			return this.custom_yukiko;
		}
		if (heroineID == HEROINE.MARIKO)
		{
			return this.custom_mariko;
		}
		return null;
	}

	// Token: 0x0600132E RID: 4910 RVA: 0x0008A304 File Offset: 0x00088504
	public CustomParameter GetMaleCustomParam(MALE_ID maleID)
	{
		if (maleID == MALE_ID.HERO)
		{
			return this.custom_hero;
		}
		if (maleID == MALE_ID.KOUICHI)
		{
			return this.custom_kouichi;
		}
		if (maleID == MALE_ID.MOB_A)
		{
			return this.custom_h_maleMobA;
		}
		if (maleID == MALE_ID.MOB_B)
		{
			return this.custom_h_maleMobB;
		}
		if (maleID == MALE_ID.MOB_C)
		{
			return this.custom_h_maleMobC;
		}
		return null;
	}

	// Token: 0x0600132F RID: 4911 RVA: 0x0008A358 File Offset: 0x00088558
	public bool IsHeroineFloped(HEROINE heroineID)
	{
		return this.personality[(int)heroineID].IsFloped(heroineID);
	}

	// Token: 0x06001330 RID: 4912 RVA: 0x0008A368 File Offset: 0x00088568
	public int GetBadgeNum()
	{
		int num = 0;
		for (int i = 0; i < this.personality.Length; i++)
		{
			if (this.personality[i].feelVagina)
			{
				num++;
			}
			if (this.personality[i].feelAnus)
			{
				num++;
			}
			if (this.personality[i].indecentLanguage)
			{
				num++;
			}
			if (this.personality[i].likeFeratio)
			{
				num++;
			}
			if (this.personality[i].likeSperm)
			{
				num++;
			}
		}
		return num;
	}

	// Token: 0x06001331 RID: 4913 RVA: 0x0008A400 File Offset: 0x00088600
	public bool IsFlopFromBadgeNum()
	{
		for (int i = 0; i < 3; i++)
		{
			if (i != 3)
			{
				int num = 0;
				if (this.personality[i].feelVagina)
				{
					num++;
				}
				if (this.personality[i].feelAnus)
				{
					num++;
				}
				if (this.personality[i].indecentLanguage)
				{
					num++;
				}
				if (this.personality[i].likeFeratio)
				{
					num++;
				}
				if (this.personality[i].likeSperm)
				{
					num++;
				}
				if (num < 3)
				{
					return false;
				}
			}
		}
		return true;
	}

	// Token: 0x06001332 RID: 4914 RVA: 0x0008A4A8 File Offset: 0x000886A8
	public bool IsAllFreeFromBadgeNum()
	{
		for (int i = 0; i < this.personality.Length; i++)
		{
			if (i != 3)
			{
				if (!this.personality[i].feelVagina)
				{
					return false;
				}
				if (!this.personality[i].feelAnus)
				{
					return false;
				}
				if (!this.personality[i].indecentLanguage)
				{
					return false;
				}
				if (!this.personality[i].likeFeratio)
				{
					return false;
				}
				if (!this.personality[i].likeSperm)
				{
					return false;
				}
			}
		}
		return true;
	}

	// Token: 0x06001333 RID: 4915 RVA: 0x0008A540 File Offset: 0x00088740
	public bool IsFlopFromBadgeNumByMariko()
	{
		Personality personality = this.personality[3];
		int num = 0;
		if (personality.feelVagina)
		{
			num++;
		}
		if (personality.feelAnus)
		{
			num++;
		}
		if (personality.indecentLanguage)
		{
			num++;
		}
		if (personality.likeFeratio)
		{
			num++;
		}
		if (personality.likeSperm)
		{
			num++;
		}
		return num >= 3;
	}

	// Token: 0x06001334 RID: 4916 RVA: 0x0008A5AC File Offset: 0x000887AC
	public bool IsAllFreeFromBadgeNumByMariko()
	{
		Personality personality = this.personality[3];
		return personality.feelVagina && personality.feelAnus && personality.indecentLanguage && personality.likeFeratio && personality.likeSperm;
	}

	// Token: 0x06001335 RID: 4917 RVA: 0x0008A604 File Offset: 0x00088804
	public void SetProgress(GamePlayData.PROGRESS next)
	{
		if (next >= this.progress)
		{
			this.progress = next;
		}
		else
		{
			GlobalData.Debug_LogWarning("进度又恢复了");
		}
	}

	// Token: 0x04001834 RID: 6196
	private SaveHeader header = new SaveHeader(5);

	// Token: 0x04001835 RID: 6197
	private GamePlayData.PROGRESS progress;

	// Token: 0x04001836 RID: 6198
	public CustomParameter custom_ritsuko;

	// Token: 0x04001837 RID: 6199
	public CustomParameter custom_akiko;

	// Token: 0x04001838 RID: 6200
	public CustomParameter custom_yukiko;

	// Token: 0x04001839 RID: 6201
	public CustomParameter custom_mariko;

	// Token: 0x0400183A RID: 6202
	public CustomParameter custom_hero;

	// Token: 0x0400183B RID: 6203
	public CustomParameter custom_kouichi;

	// Token: 0x0400183C RID: 6204
	public CustomParameter custom_h_maleMobA;

	// Token: 0x0400183D RID: 6205
	public CustomParameter custom_h_maleMobB;

	// Token: 0x0400183E RID: 6206
	public CustomParameter custom_h_maleMobC;

	/// <summary>个性</summary>
	public Personality[] personality = new Personality[4];

	// Token: 0x04001840 RID: 6208
	public MALE_ID lastSelectMale;

	// Token: 0x04001841 RID: 6209
	public HEROINE lastSelectFemale;

	// Token: 0x04001842 RID: 6210
	public VISITOR lastSelectVisitor = VISITOR.NONE;

	// Token: 0x04001843 RID: 6211
	public int lastSelectMap;

	// Token: 0x04001844 RID: 6212
	public int lastSelectTimeZone;

	// Token: 0x04001845 RID: 6213
	public bool unlockWeaknessRecovery;

	// Token: 0x04001846 RID: 6214
	public bool unlockShowHitArea;

	// Token: 0x04001847 RID: 6215
	public bool unlockFastXtc;

	// Token: 0x04001848 RID: 6216
	public bool readAllFreeMessage;

	// Token: 0x04001849 RID: 6217
	public bool readAllFreeWithAdd;

	// Token: 0x020002EF RID: 751
	public enum PROGRESS
	{
		// Token: 0x0400184B RID: 6219
		FIRST_RITSUKO,
		// Token: 0x0400184C RID: 6220
		FIRST_AKIKO,
		// Token: 0x0400184D RID: 6221
		FIRST_YUKIKO,
		// Token: 0x0400184E RID: 6222
		RESIST,
		// Token: 0x0400184F RID: 6223
		FLIPFLOP_YUKIKO,
		// Token: 0x04001850 RID: 6224
		FLIPFLOP_AKIKO,
		// Token: 0x04001851 RID: 6225
		FLIPFLOP_RITSUKO,
		// Token: 0x04001852 RID: 6226
		FLOP,
		// Token: 0x04001853 RID: 6227
		END_YUKIKO_1,
		// Token: 0x04001854 RID: 6228
		END_SISTERS,
		// Token: 0x04001855 RID: 6229
		END_YUKIKO_2,
		// Token: 0x04001856 RID: 6230
		CLEAR_MAIN,
		// Token: 0x04001857 RID: 6231
		FIRST_MARIKO,
		// Token: 0x04001858 RID: 6232
		RESIST_MARIKO,
		// Token: 0x04001859 RID: 6233
		FLIPFLOP_MARIKO,
		// Token: 0x0400185A RID: 6234
		FLOP_MARIKO,
		// Token: 0x0400185B RID: 6235
		END_MARIKO,
		// Token: 0x0400185C RID: 6236
		ALL_FREE
	}
}
